const Controller = require('egg').Controller

class HomeController extends Controller {

  async index() {

    const { ctx, service } = this

    //电池
    const [ batteryData ] = await service.homeService.getTableData('t_realdata_BatRout', 'rd_BatAllVol, rd_RemCap')

    //UPS
    const [ upsData ] = await service.homeService.getTableData('t_realdata_three', 'rd_InVol1, rd_OutPower1')

    //环境(精密空调)
    const [ envData ] = await service.homeService.getTableData('t_realdata_generalair', 'rd_air_innertemp, rd_air_innerhum')

    //告警
    const alarmData = await service.homeService.getDeviceAlarmCount()

    const data = {
      batteryData,
      upsData,
      envData,
      alarmData
    }
    ctx.helper.success({ ctx, res: data })
  }
}

module.exports = HomeController
